from fastapi import FastAPI, BackgroundTasks
from starlette.concurrency import run_in_threadpool


def create_app():
    app = FastAPI()
    return app


app = create_app()


@app.on_event("startup")
async def init_scheduler():
    from task import run
    run()


if __name__ == '__main__':
    import uvicorn

    uvicorn.run(
        app='client:app',
        host="127.0.0.1",
        log_level="debug",
        port=8888,
        loop="asyncio",
        # workers=4,
    )
